<template>
  <div class="q-pa-md" style="padding:0px;">
    <q-table
      title="任务列表"
      :data="data"
      :columns="columns"
      row-key="name"
      separator="cell"
      :pagination="initialPagination"
    >
    <template v-slot:top>
        <q-btn color="primary" label="统一下单" @click="unite = true" />
        <q-btn class="q-ml-sm" color="secondary" label="批量下单" @click="batch = true" />
        <q-space />
        <q-input borderless dense debounce="300" color="primary" v-model="filter" placeholder="搜索">
          <template v-slot:append>
            <q-icon name="search" />
          </template>
        </q-input>
    </template>

    <template v-slot:body="props">
        <q-tr :props="props">
          <q-td key="name" :props="props">
            {{ props.row.name }}
          </q-td>
          <q-td key="calories" :props="props">
            {{ props.row.calories }}
          </q-td>
          <q-td key="fat" :props="props">
            <div class="text-pre-wrap">{{ props.row.fat }}</div>
          </q-td>
          <q-td key="carbs" :props="props">
            {{ props.row.carbs }}
          </q-td>
          <q-td key="carbs" :props="props">
            {{ props.row.carbs }}
          </q-td>
          <q-td key="carbs" :props="props">
            {{ props.row.carbs }}
          </q-td>
          <q-td key="carbs" :props="props">
            {{ props.row.carbs }}
          </q-td>
          <q-td key="protein" :props="props">{{ props.row.protein }}</q-td>
          <q-td key="sodium" :props="props">{{ props.row.sodium }}</q-td>
          <q-td key="calcium" :props="props">{{ props.row.calcium }}</q-td>
          <q-td key="iron" :props="props">{{ props.row.iron }}</q-td>
          <q-td key="iron" :props="props">{{ props.row.iron }}</q-td>
          <q-td key="iron" :props="props">
            <q-btn size="xs" padding="5px 5px" color="primary" @click="rankConfirm = true">
              <q-icon name="speed" />
              <div>加速</div>
            </q-btn>
            &nbsp;
            <q-btn size="xs" padding="5px 5px" color="red" @click="stopConfirm = true">
              <q-icon name="stop" />
              <div>停止</div>
            </q-btn>
          </q-td>
        </q-tr>
    </template>
    </q-table>

    <!-- 统一下单 -->
    <q-dialog v-model="unite" persistent>
      <q-card style="min-width:450px">
        <q-card-section>
          <div class="text-h6">统一下单</div>
        </q-card-section>

        <q-card-section class="q-pt-none">
          <q-input label="视频链接/ID" v-model="address"/>
          <q-input
            label="点赞数量"
            v-model.number="address"
            type="number"
            hint="单价 ： 19 金币"
            style="margin-top:20px;"
          />
          <q-input
            label="关注数量"
            v-model.number="address"
            type="number"
            hint="单价 ： 15 金币"
            style="margin-top:20px;"
          />
          <div class="q-gutter-sm" style="margin-top:20px;">
            <q-radio v-model="shape" val="line" label="普通" />
            <q-radio v-model="shape" val="rectangle" label="加速" />
            <q-radio v-model="shape" val="ellipse" label="特价" />
          </div>
        </q-card-section>

        <q-card-actions align="right" class="text-primary">
          <q-btn flat label="取消" v-close-popup />
          <q-btn flat label="提交" v-close-popup />
        </q-card-actions>
      </q-card>
    </q-dialog>

    <!-- 批量下单 -->
    <q-dialog v-model="batch" persistent>
      <q-card style="min-width:600px">
        <q-card-section>
          <div class="text-h6">批量下单</div>
        </q-card-section>

        <q-card-section class="q-pt-none">
          <q-input
            v-model="text"
            filled
            type="textarea"
             hint="下单格式：
D音短链接/视频ID  任务数量  任务类型【1=关注,2=点赞,3=评论,4=播放,5=视频转发,6=评论赞】  执行速度【0=普通,1=极速,2=特价慢速。选填项，默认为0】"
          />
        </q-card-section>

        <q-card-actions align="right" class="text-primary">
          <q-btn flat label="取消" v-close-popup />
          <q-btn flat label="提交" v-close-popup />
        </q-card-actions>
      </q-card>
    </q-dialog>

    <!-- 加速确认-->
    <q-dialog v-model="rankConfirm" persistent>
      <q-card>
        <q-card-section class="row items-center">
          <q-avatar icon="speed" color="primary" text-color="white" />
          <span class="q-ml-sm">确定加速此任务吗？</span>
        </q-card-section>

        <q-card-actions align="right">
          <q-btn flat label="取消" color="red" v-close-popup />
          <q-btn flat label="确定" color="primary" v-close-popup />
        </q-card-actions>
      </q-card>
    </q-dialog>

    <!-- 停止确认-->
    <q-dialog v-model="stopConfirm" persistent>
      <q-card>
        <q-card-section class="row items-center">
          <q-avatar icon="stop" color="red" text-color="white" />
          <span class="q-ml-sm">确定停止此任务吗？</span>
        </q-card-section>

        <q-card-actions align="right">
          <q-btn flat label="取消" color="red" v-close-popup />
          <q-btn flat label="确定" color="primary" v-close-popup />
        </q-card-actions>
      </q-card>
    </q-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      initialPagination: {
        sortBy: 'desc',
        descending: false,
        page: 1,
        rowsPerPage: 25
      },
      unite: false,
      batch: false,
      rankConfirm: false,
      stopConfirm: false,
      filters: '',
      address: '',
      shape: 'line',
      text: '',
      columns: [
        {
          name: 'name',
          required: true,
          label: '任务编号',
          align: 'left',
          field: row => row.name,
          format: val => `${val}`,
          sortable: true
        },
        { name: 'calories', align: 'center', label: '链接ID', field: 'calories' },
        { name: 'fat', align: 'center', label: '任务量', field: 'fat' },
        { name: 'carbs', align: 'center', label: '起始', field: 'carbs' },
        { name: 'protein', align: 'center', label: '终止', field: 'protein' },
        { name: 'sodium', align: 'center', label: '进度', field: 'sodium' },
        { name: 'calcium', align: 'center', label: '任务类型', field: 'calcium' },
        { name: 'iron', align: 'center', label: '速度', field: 'iron' },
        { name: 'iron', align: 'center', label: '添加时间', field: 'iron' },
        { name: 'iron', align: 'center', label: '状态', field: 'iron' },
        { name: 'iron', align: 'center', label: '单价', field: 'iron' },
        { name: 'iron', align: 'center', label: '任务明细', field: 'iron' },
        { name: 'iron', align: 'center', label: '操作', field: 'iron' }
      ],
      data: [
        {
          name: 'Frozen Yogurt',
          calories: 159,
          fat: 6.0,
          carbs: 24,
          protein: 4.0,
          sodium: 87,
          calcium: '14%',
          iron: '1%'
        },
        {
          name: 'Ice cream sandwich',
          calories: 237,
          fat: 9.0,
          carbs: 37,
          protein: 4.3,
          sodium: 129,
          calcium: '8%',
          iron: '1%'
        },
        {
          name: 'Eclair',
          calories: 262,
          fat: 16.0,
          carbs: 23,
          protein: 6.0,
          sodium: 337,
          calcium: '6%',
          iron: '7%'
        },
        {
          name: 'Cupcake',
          calories: 305,
          fat: 3.7,
          carbs: 67,
          protein: 4.3,
          sodium: 413,
          calcium: '3%',
          iron: '8%'
        },
        {
          name: 'Gingerbread',
          calories: 356,
          fat: 16.0,
          carbs: 49,
          protein: 3.9,
          sodium: 327,
          calcium: '7%',
          iron: '16%'
        },
        {
          name: 'Jelly bean',
          calories: 375,
          fat: 0.0,
          carbs: 94,
          protein: 0.0,
          sodium: 50,
          calcium: '0%',
          iron: '0%'
        },
        {
          name: 'Lollipop',
          calories: 392,
          fat: 0.2,
          carbs: 98,
          protein: 0,
          sodium: 38,
          calcium: '0%',
          iron: '2%'
        },
        {
          name: 'Honeycomb',
          calories: 408,
          fat: 3.2,
          carbs: 87,
          protein: 6.5,
          sodium: 562,
          calcium: '0%',
          iron: '45%'
        },
        {
          name: 'Donut',
          calories: 452,
          fat: 25.0,
          carbs: 51,
          protein: 4.9,
          sodium: 326,
          calcium: '2%',
          iron: '22%'
        },
        {
          name: 'KitKat',
          calories: 518,
          fat: 26.0,
          carbs: 65,
          protein: 7,
          sodium: 54,
          calcium: '12%',
          iron: '6%'
        }
      ]
    }
  }
}
</script>
